import pickle
import base64

class CookieSecret(object):
    @classmethod
    def dumps(cls,data):
        #转换类型--bytes
        pickle_bytes = pickle.dumps(data)
        #转成64编码
        base64_encode = base64.b64encode(pickle_bytes)
        #bytes--str
        return base64_encode.decode()

    #解密
    @classmethod
    def loads(cls,data):
        #解码
        base64_decode = base64.b64decode(data)
        #pickle---原始数据
        data = pickle.loads(base64_decode)
        return data